
<meta charset="utf-8" />	

<form class="form-horizontal" role="form"  onsubmit="return submitForm(this);"
 action="mpcoop/cooporgmer/coopOrgMerEdit/edit.do" id="cooporgMerEdit_form">
	<!-- #section:elements.form -->
	<br/>
	<!-- 
	 * Input属性说明:
	 * validate="true"  是否需要验证字段
	 * msg="错误时提示信息"        
	 * datatype="数据类型"
	-->
	<div class="form-group">
		<label class="col-sm-2 control-label no-padding-right"
			for="form-field-1"> 合作机构编号： </label>
		<div class="col-sm-4">
               

			<input type="text" id="cooporgNo" name="cooporgNo" placeholder="请输入[合作机构编号]" 
				class="col-xs-10 col-sm-7" readonly="readonly"/>
		</div>
		<label class="col-sm-2 control-label no-padding-right"
			for="form-field-1"> 商户状态: </label>
		<div class="col-sm-4">
             <select 
						rel="obj.MERSTATUS"
						location="local" 
						name="merStatus" 
						id="merStatus" 
						data-placeholder="请选择状态" style="width: 120px;vertical-align:middle;">
						<option value='' >--请选择--</option>
			</select>
		</div>
	</div>
	
	<div class="form-group">
		
		<label class="col-sm-2 control-label no-padding-right"
			for="form-field-1"> 商户编号： </label>
		<div class="col-sm-4">

			<input type="text" id="merNo" name="merNo" placeholder="请输入[商户编号]" 
				class="col-xs-10 col-sm-7" readonly="readonly" />
		</div>
		<label class="col-sm-2 control-label no-padding-right"
			for="form-field-1"> 商户名称： </label>
		<div class="col-sm-4">

			<input type="text" id="merName" name="merName" placeholder="请输入[商户名称]" 
				class="col-xs-10 col-sm-7"  />
		</div>
	</div>
	
	  <div class="form-group" >			
				<label class="col-sm-2 control-label no-padding-right"
						for="form-field-1"> 终端编号： </label>
				<div class="col-sm-4">

					<input type="text" id="terNo" name="terNo" placeholder="请输入[终端编号]" 
							class="col-xs-10 col-sm-7"  readonly="readonly"/>
				</div>
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1"> 费率类型: </label>
				<div class="col-sm-4">
		             <select 
								rel="obj.RATETYPE"
								location="local" 
								name="rateType" 
								id="rateType" 
								data-placeholder="" style="width: 120px;vertical-align:middle;" >
								<option value='' >--请选择--</option>
					</select>
				</div>
		</div>
	<div class="form-group" id="pos_div">
		<div class="form-group" >	
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1"> 费率封顶： </label>
				<div class="col-sm-4">
		
					<input type="text" id="rateTop" name="rateTop" placeholder="" 
						class="col-xs-10 col-sm-7"  />
				</div>
				<label class="col-sm-2 control-label no-padding-right"
					for="form-field-1"> 费率类型 封顶金额： </label>
				<div class="col-sm-4">
		
					<input type="text" id="rateTypeTop" name="rateTypeTop" placeholder="" 
						class="col-xs-10 col-sm-7"  validate="true" />
				</div>
	 </div>
	 
	 <div class="form-group" id="shortcut_div" style="display: none;">
		<label class="col-sm-2 control-label no-padding-right"
			for="form-field-1"> T0成本费率(%)： </label>
		<div class="col-sm-4">

			<input type="text" id="rateT0" name="rateT0" placeholder="请输入[大商户T0刷卡成本费率(%)]" 
				class="col-xs-10 col-sm-7"  />
		</div>
		<label class="col-sm-2 control-label no-padding-right"
			for="form-field-1"> T1成本费率(%)： </label>
		<div class="col-sm-4">

			<input type="text" id="rateT1" name="rateT1" placeholder="请输入[大商户T1刷卡成本费率(%)]" 
				class="col-xs-10 col-sm-7"  />
		</div>
  </div>
	
	<div class="form-group">
		<label class="col-sm-2 control-label no-padding-right"
			for="form-field-1"> 主密钥： </label>
		<div class="col-sm-4">

			<input type="text" id="merKey" name="merKey" placeholder="请输入[商户密钥(快捷通道/终端主密钥)]" 
				class="col-xs-10 col-sm-7"  />
		</div>
		<label class="col-sm-2 control-label no-padding-right"
			for="form-field-1"> 主密钥校验值： </label>
		<div class="col-sm-4">

			<input type="text" id="checkValue" name="checkValue" placeholder="请输入[主密钥校验值]" 
				class="col-xs-10 col-sm-7"  />
		</div>
	</div>

	<div class="form-group">
		<label class="col-sm-2 control-label no-padding-right"
			for="form-field-1"> 日交易限额： </label>
		<div class="col-sm-4">

			<input type="text" id="dtLimit" name="dtLimit" placeholder="请输入[日交易限额]" 
				class="col-xs-10 col-sm-7"  />
		</div>
		<label class="col-sm-2 control-label no-padding-right"
			for="form-field-1"> 月交易限额： </label>
		<div class="col-sm-4">

			<input type="text" id="mtLimit" name="mtLimit" placeholder="请输入[月交易限额]" 
				class="col-xs-10 col-sm-7"  />
		</div>
	</div>

	<div class="form-group">
		<label class="col-sm-2 control-label no-padding-right"
			for="form-field-1"> 单笔最低交易额： </label>
		<div class="col-sm-4">

			<input type="text" id="lowLimit" name="lowLimit" placeholder="请输入[单笔最低交易额]" 
				class="col-xs-10 col-sm-7"  />
		</div>
		<label class="col-sm-2 control-label no-padding-right"
			for="form-field-1"> 单笔最高交易额： </label>
		<div class="col-sm-4">

			<input type="text" id="highLimit" name="highLimit" placeholder="请输入[单笔最高交易额]" 
				class="col-xs-10 col-sm-7"  />
		</div>
	</div>

	<div class="form-group">
		
		<label class="col-sm-2 control-label no-padding-right"
			for="form-field-1" > 路由商户编号： </label>
		<div class="col-sm-4">

			<input type="text" id="routeMerId" name="routeMerId" placeholder="需要绑定的系统商户编号" 
				class="col-xs-10 col-sm-7" />
			
			<input type="hidden" id="editUserName" name="editUserName" placeholder="请输入[编辑员]" 
				class="col-xs-10 col-sm-7" readonly="readonly" />
		</div>
		
		<!-- <label class="col-sm-2 control-label no-padding-right"
			for="form-field-1" > 编辑员： </label>
		<div class="col-sm-4">

			<input type="text" id="editUserName" name="editUserName" placeholder="请输入[编辑员]" 
				class="col-xs-10 col-sm-7" readonly="readonly" />
		</div> -->
	</div> 
	<input type="hidden" id="editUserId" name="editUserId"/>

	
	<div class="form-actions align-right  form-button-box" style="margin-top: 10px">
			<button class="btn btn-info" type="submit">
				保存
			</button>
			&nbsp; 
			<button class="btn" type="button" onclick="javascript:dialog.close(this);">
				 关闭
			</button>
		</div>
	
</form>
<script type="text/javascript">

$(document).ready(function() {
	 var p = dialog.getById('dlg-coopOrgMeredit');
	//设置页面初始值
	var editUserId=$("#editUserId").attr("value",p.dataParam.editUserId);
	$("#editUserName").attr("value",p.dataParam.editUserName);
	
	if ($("#rateTypeTop").val() == 0){
		$("#rateTypeTop").attr("disabled","disabled");
	}
});
$(document).ready(function(){
    var time=setInterval(function(){
		if($("#cooporgNo").val()!=''){
			clearInterval(time);
			$.ajax({
				type : "post",
				url : "mpcoop/cooporgmer/queryCooporgInfById.do",
				data:{cooporgNo:$("#cooporgNo").val()},
				dataType : 'json',
				async:true,
				success : function(result) {
					if (result.rspcod != 200) {
						msg.alert("错误", result.rspmsg + " 错误代码："+ result.rspcod, 'error');
					} else {
						coopType=result.obj.coopType;
						if(coopType == "0" ){//收单
							$("#pos_div").show();
							$("#shortcut_div").hide();
							
						}
						if(coopType == "1" ){
							$("#pos_div").hide();
							$("#shortcut_div").show();
						}
					}
				},
				error : function(XMLHttpRequest, textStatus) {
					msg.alert("错误", "错误代码：" + XMLHttpRequest.status + ",错误描述："+ textStatus, 'error');
				}
			});
		}
	},100); 
    
});
$(document).ready(function(){
		$('#rateType').change(
				function(){
				    var rateType=$(this).children('option:selected').val();
					if(rateType == '1' || rateType == '2' || rateType == '3' ){
						$("#rateTypeTop").attr("disabled","disabled");    			
					}else if(rateType == '4' || rateType == '5'){
						$("#rateTypeTop").removeAttr("disabled");
					}
				}	
		); 
});


function submitForm(obj){
	var merStatus=$("#merStatus option:selected").val();
	if(merStatus==''){
		alertMsg.error('请选择商户状态');
		return false;
	}
	if($("#pos_div").is(":visible")){
		var rateType=$("#rateType option:selected").val();
		if(rateType==''){
			alertMsg.error('请选择费率类型');
			return false;
		}
		if(rateType == '4' || rateType == '5'){
			var rateTypeTop=$("rateTypeTop").val();
			if(rateTypeTop==''){
				alertMsg.error('请输入费率类型 封顶金额');
				return false;
			}
		}
	}
	return validateCallback(obj,editUserDone);
}

function editUserDone(result){
	dialogAjaxDone(result);
	if(result.rspcod== 200){
		msg.alert("提示",result.rspmsg,'correct');
		$("#grid-table").trigger("reloadGrid");
		dialog.closeById('dlg-coopOrgMerAdd');
	}else{
		msg.alert("错误",result.rspmsg+" 错误代码："+result.rspcod,'error');
	}
}
</script>
